package com.icreate.storm.methods.indicators.fieldCreater;

import com.icreate.entity.indicator.IndicatorID;
import com.icreate.entity.indicator.S1_MMEfield;
import com.icreate.storm.methods.common.DateMethod;
import com.icreate.storm.methods.indicators.fieldCreater.FieldCreater;

/**
 * Created by icreate on 2017/5/21.
 */
public class S1_MMEfieldCreater extends BaseSubstring implements FieldCreater<S1_MMEfield> {
    private int[] indexsBuffer=new int[29];
    // private int splitIndexes[] = new int[28];

    public S1_MMEfield create(String s) {
 /*
        String[] cells = s.split(",");
        String ts = cells[10];
        String cellid = cells[28];
        String imsi = cells[6];
        String imei = cells[7];
        if (ts.equals("") || cellid.equals("") || imsi.equals(""))
            return null;
        String hour = DateMethod.getHour(ts);
        S1_MMEfield field = new S1_MMEfield(DateMethod.getDate(ts), cellid, imsi, imei, hour);
        field.setStatus(cells[12]);
        field.setProcedureType(cells[9]);
        field.setCause(cells[13]);
 */
          setSplitIndexes(s);
        String ts =getCell(10);; //substring(s,splitIndexes[9],splitIndexes[10]);
        String cellid = getCell(28);// cells[28];
        String imsi = getCell(6); //cells[6];
        String imei = getCell(7);//cells[7];
        if (ts.equals("") || cellid.equals("") || imsi.equals(""))
            return null;
        String hour = DateMethod.getHour(ts);
        S1_MMEfield field = new S1_MMEfield(DateMethod.getDate(ts), cellid, imsi, imei, hour);
        field.setStatus(getCell(12));
        field.setProcedureType(getCell(9));
        field.setCause(getCell(13));
        return field;
    }

    @Override
    protected int[] getIndexBuffer() {
        return indexsBuffer;
    }
  /*
    private void setSplitIndexes(String s){
        for (int i = 0; i < splitIndexes.length; i++) {
            if(i==0)
         splitIndexes[i]= s.indexOf(",");
            else splitIndexes[i]=s.indexOf(",",splitIndexes[i-1]+1);
        }
    }
    */
}
